<template>
  <div>
    <el-table  :data="table.data" :default-sort="{prop : 'orgNo', prop: 'orgName'}" border highlight-current-row fit>
      <el-table-column align="center" type="index" width="50"></el-table-column>
      <el-table-column align="center" label="机构号" prop="orgNo"></el-table-column>
      <el-table-column align="center" label="机构名称" prop="orgName"></el-table-column>
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <a @click="Oauth(scope.row.orgNo)"  icon="el-icon-edit">授权</a>
        </template>
      </el-table-column>
    </el-table>

    <el-dialog :title="authDialog.title" :visible.sync="authDialog.show" width="600px" :close-on-click-modal="false">
      <iframe :src="authDialog.url"></iframe>
      <el-button @click="authDialog.show = false">取消</el-button>
    </el-dialog>
  </div>
</template>
<script>
  import { weixinOauth } from '../../../api/user'
  export default {
    data() {
      return {
        table: {
          data: [
            {
              index: 1,
              orgNo: 90603, // 宁德农商银行
              orgName: '福鼎联社农商银行'
            }
          ]
        },
        authDialog: {
          title: '微信授权',
          show: false,
          url: ''
        }
      }
    },
    mounted(){
      debugger
      let orgName = ""
      let orgNo = process.env.ORG_NO
      this.table.data[0].orgNo = orgNo
      if(orgNo == 90602){
        orgName = "宁德农商银行";
      }else if(orgNo == 90603){
        orgName = "福鼎联社农商银行";
      }else if(orgNo == 90602){
        orgName = "福鼎联社农商银行";
      }else if(orgNo == 90110){
        orgName = "罗源联社农商银行";
      }
      this.table.data[0].orgName = orgName
   },
    methods: {
      Oauth(orgNo) {
        weixinOauth(orgNo).then(function(res) {
          if (res && res.data) {
            window.open(res.data.url, '_blank')
          }
        })
      },
      clearDialogData() {
        this.authDialog.url = null
      }
    }
  }
</script>
<style lang="scss" scoped>
</style>
